#pragma once
#include "gtest/gtest.h"
#include "DataStructure/Input/Property/BeamSectionStandardTypes.h"
#include "../Interface/BarSectionFormulaCalculatorFactory.h"
#include "../Bar/Hat1SectionFormulaCalculator.h"

using SG::Algebra::Point;
using namespace SG::DataStructure::FEM;
using SG::FEMSolver::Element::BarSectionFormulaCalculatorFactory;
using SG::FEMSolver::Element::Hat1SectionFormulaCalculator;

// 将 BarSectionFormulaCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BarSectionFormulaCalculatorFactoryTest, Hat1SectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BarSectionFormulaCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_HAT1);
    auto hat1CalculatorPtr = dynamic_cast<Hat1SectionFormulaCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != hat1CalculatorPtr);
}

// Hat1 截面属性计算测试
TEST (BarSectionFormulaCalculatorTest, Hat1Section)
{
    // Input data
    PBARLData section;
    section.m_id  = 2;
    section.m_mId = 3;
    section.SetGroup ("MSCBML0");
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_HAT1);
    section.m_dimension = {10.0, 8.0, 6.0, 2.0, 1.5};
    section.m_nsm = 10.0;

    // Test data
    Hat1SectionFormulaCalculator calculator;
    PBARData propertyTest;
    Point centroidTest;
    calculator.Compute (section, _OUT propertyTest, _OUT centroidTest);

    // Target data
    PBARData propertyTarget;
    propertyTarget.m_id  = 2;
    propertyTarget.m_mId = 3;
    propertyTarget.m_A   = 53.0;
    // propertyTarget.m_yS = 6.8171129;  // ToDo（正确值为：1.770398）
    // propertyTarget.m_zS = 0.0;
    // propertyTarget.m_yC = 3.448113;
    // propertyTarget.m_zC = 0.0;
    propertyTarget.m_I1  = 309.274;
    propertyTarget.m_I2  = 369.6667;
    propertyTarget.m_I12 = 0.0;
    propertyTarget.m_J   = 286.1743;
    propertyTarget.m_K1  = 0.49056604;
    propertyTarget.m_K2  = 0.50943396;
    propertyTarget.m_NSM = 10.0;
    propertyTarget.m_FE  = 0.0;
    propertyTarget.SetStressPoints ({-3.448113, -5.0, -3.448113, 5.0, 4.551887, -3.0, 4.551887, 3.0});
    Point centroidTarget;

    // Check
    ASSERT_TRUE (propertyTarget == propertyTest);
    ASSERT_TRUE (centroidTarget == centroidTest);
}